package com.dhcc.activemq.comsumer;
 
import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Component;
 
/**
 * 
* <p>标题: QueueConsumer.java</p>
* <p>业务描述:队列消费</p>
* <p>公司:东华软件股份公司</p>
* <p>版权:dhcc2013</p>
* @author 胡凯
* @date 2019年7月30日
* @version V1.0
 */
@Component
public class MqConsumer {
 
	//queue平均分配
	//destination	队列名称
	//containerFactory	监听工厂名称见ActiveMqConfig
    @JmsListener(destination = "stringQueue", containerFactory = "jmsListenerContainerQueue")
    public void receiveStringQueueA(String msg) {
        System.out.println("接收到消息A...." + msg);
    }
    @JmsListener(destination = "stringQueue", containerFactory = "jmsListenerContainerQueue")
    public void receiveStringQueueB(String msg) {
    	System.out.println("接收到消息B...." + msg);
    }
    //topic都能收到
    //接收topicA
    @JmsListener(destination = "stringTopic", containerFactory = "jmsListenerContainerTopic")
    public void receiveStringTopicA(String msg) throws Exception {
    	Thread.sleep(9000);
    	System.out.println("接收到主题A...." + msg);
    }
    //接收topicB
    @JmsListener(destination = "stringTopic", containerFactory = "jmsListenerContainerTopic")
    public void receiveStringTopicB(String msg) {
    	System.out.println("接收到主题B...." + msg);
    }
    //接收topicC
    @JmsListener(destination = "stringTopic", containerFactory = "jmsListenerContainerTopic")
    public void receiveStringTopicC(String msg) {
    	System.out.println("接收到主题C...." + msg);
    }
}